home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C04 / Scoperes.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  422 b   |  21 lines

  1. //: C04:Scoperes.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Global scope resolution
  7. int a;
  8. void f() {}
  9.  
  10. struct S {
  11.   int a;
  12.   void f();
  13. };
  14.  
  15. void S::f() {
  16.   ::f();  // Would be recursive otherwise!
  17.   ::a++;  // Select the global a
  18.   a--;    // The a at struct scope
  19. }
  20. int main() { S s; f(); } ///:~
  21.